BASEDIR = d:
DMDBINDIR = $(BASEDIR)\dmd\bin
DMD = $(DMDBINDIR)\dmd
DIGCBASE=$(DMDBINDIR)\digc -unittest
DIGC=$(DIGCBASE) -release -O
# -windowed                         
LIBDIR=$(BASEDIR)\dm\lib
PLATFORM=net/BurtonRadons/dig/platform
# was windows
DIGCDIR=net\BurtonRadons\digc

DIG_LIBRARIES = advapi32.lib comdlg32.lib gdi32.lib comctl32.lib shell32.lib

help:
    @echo Use "make install" to build and install normally.
    @echo You can then try tests individually using make with:
    @echo .
    @echo cartoonTest - A cartoon shading example.
    @echo halhelloTest - A simple control test.
    @echo scintillaTest - A sample of the Scintilla control (Scintilla not included).
    @echo themeExplorerTest - A utility for exploring Windows XP themes, requires Windows XP.
    @echo .
    @echo Use "make clean" to delete executables and some other files.
    @echo .
    @echo If you didn't install dmd to the root directory of your hard
    @echo drive or if you develop on a different hard drive, you can
    @echo pass "BASEDIR=XXX" to specify the path before the dmd and dm
    @echo directories.  For example, "make install BASEDIR=c:/dev" would
    @echo be appropriate if "c:/dev/dmd/bin" would be the DMD binary
    @echo directory.  Do not put in a suffixed slash.
    
net.BurtonRadons.parse: net.BurtonRadons.parse.library net.BurtonRadons.parse.docgen

net.BurtonRadons.parse.library:
    digc net/BurtonRadons/parse/*.d -lib=net_BurtonRadons_parse -install
    
net.BurtonRadons.parse.docgen:
    digc net/BurtonRadons/parse/programs/docgen.d -exe=docgen -then=docgen

net/BurtonRadons/dig/common/baseDirectory.d: makefile
    @echo module net.BurtonRadons.dig.common.baseDirectory; char [] digPlatformBaseDirectory = "$(BASEDIR)"; > net/BurtonRadons/dig/common/baseDirectory.d
    
dstriptest:
    make dstripcopy BASEDIR=$(BASEDIR)
    timerun dstripcopy *.d t

install: net/BurtonRadons/dig/common/baseDirectory.d dig dfilter cartoon halhello deditTest

test:
    make dig BASEDIR=$(BASEDIR)
    make halhelloTest BASEDIR=$(BASEDIR)

clean:
    del *.exe *.bak net/BurtonRadons/dig/common/baseDirectory.d

$(DMDBINDIR)\dfilter.exe: digc $(DIGCDIR)\dfilter.d
    $(DIGCBASE) $(DIGCDIR)\dfilter.d -exe=$(DMDBINDIR)\dfilter

dfilter: $(DMDBINDIR)\dfilter.exe

$(DMDBINDIR)\timerun.exe: digc $(DIGCDIR)\timerun.d
    $(DIGCBASE) $(DIGCDIR)\timerun.d -exe=$(DMDBINDIR)\timerun

timerun: $(DMDBINDIR)\timerun.exe

$(DMDBINDIR)\digc.exe: $(DIGCDIR)\digc.d $(DIGCDIR)\omflistexports.d $(DIGCDIR)\strip.d $(DIGCDIR)\libraryRegistrar.d $(DIGCDIR)\sys.d $(DIGCDIR)\sysBase.d $(DIGCDIR)\program.d
    $(DMD) $(DIGCDIR)\digc.d $(DIGCDIR)\omflistexports.d $(DIGCDIR)\strip.d $(DIGCDIR)\libraryRegistrar.d $(DIGCDIR)\sys.d $(DIGCDIR)\sysBase.d $(DIGCDIR)\program.d kernel32.lib -unittest net\BurtonRadons\dig\common\baseDirectory.d
    copy digc.exe $(DMDBINDIR)
    +del digc.obj digc.map digc.exe omflistexports.obj strip.obj libraryRegistrar.obj sys.obj sysBase.obj program.obj

digc: $(DMDBINDIR)\digc.exe

digcTest:
    make digc BASEDIR=$(BASEDIR)
    echo void test () { printf ("Hello from DLL!\n"); } > foo.d
    digc foo.d -lib=foo -shared -install
    del foo.d
    digc bar.d
    bar

$(DMDBINDIR)\dstripcopy.exe: digc $(DIGCDIR)\strip.d
    $(DIGCBASE) $(DIGCDIR)\strip.d -version=dstripcopy -exe=$(DMDBINDIR)\dstripcopy -unittest -O -inline

dstripcopy: $(DMDBINDIR)\dstripcopy.exe

dig.lib:
    $(DIGC) -lib=dig net/BurtonRadons/dig/main.d $(PLATFORM)/*.d net/BurtonRadons/dig/common/*.d -not=$(PLATFORM)/canvasGL.d -not=net/BurtonRadons/dig/common/glEnums.d $(DIG_LIBRARIES) -install
    $(DIGC) -then="copy *.dll &(SystemDirectory)"

diggl.lib:
    $(DIGC) -lib=diggl net/BurtonRadons/dig/gl.d net/BurtonRadons/dig/common/glEnums.d $(PLATFORM)/canvasGL.d opengl32.lib -install

libs: dig.lib diggl.lib

importLibraries: opengl32.lib shell32.lib glu32.lib
    rmdir /S /Q $(BASEDIR)\dmd\src\dig
    copy opengl32.lib $(LIBDIR)
    copy shell32.lib $(LIBDIR)
    copy glu32.lib $(LIBDIR)
    
dig: digc dstripcopy timerun dig.lib diggl.lib importLibraries

# Requires dig

deditexec.exe:
    @$(DIGCBASE) net/BurtonRadons/dedit/deditexec.d -exe=deditexec

dedit.exe:
    @$(DIGC) net/BurtonRadons/dedit/*.d net/BurtonRadons/dedit/highlight/*.d -exe=dedit -not=net/BurtonRadons/dedit/deditexec.d

dedit: deditexec.exe dedit.exe
    
deditFull: net/BurtonRadons/dig/common/baseDirectory.d dig dfilter dedit
    
deditTest:
    make dedit BASEDIR=$(BASEDIR)
    dedit

deditRun:
    copy dedit.exe dedit2.exe
    dedit2
    
cartoon:
    $(DIGC) net/BurtonRadons/dig/examples/cartoon.d -exe=cartoon

cartoonTest:
    make cartoon BASEDIR=$(BASEDIR)
    cartoon

halhello:
    $(DIGC) net/BurtonRadons/dig/examples/halhello.d -exe=halhello

halhelloTest:
    make halhello BASEDIR=$(BASEDIR)
    halhello

scintilla:
    $(DIGC) net/BurtonRadons/dig/examples/scintilla.d -exe=scintilla

scintillaTest:
    make scintilla BASEDIR=$(BASEDIR)
    scintilla

themeExplorer:
    $(DIGC) net/BurtonRadons/dig/examples/themeExplorer.d -exe=themeExplorer

themeExplorerTest:
    make themeExplorer BASEDIR=$(BASEDIR)
    themeExplorer

opengl32.lib: opengl32.def
    implib opengl32.lib opengl32.def

shell32.lib: shell32.def
    implib shell32.lib shell32.def

glu32.lib: glu32.def
    implib glu32.lib glu32.def
    
spyl:
    digc -lib=net_BurtonRadons_spyl net/BurtonRadons/spyl/*.d -install
    
spylTestMain:
    digc net/BurtonRadons/spyl/main.d -version=spylTest -exe=spyl -then=spyl

spylTest: spyl spylTestMain

deditFullRun: deditFull deditRun


